FROM python:alpine

ENV TZ=Asia/Shanghai \
    DIR=/app \
    PUID=99 \
    PGID=100

WORKDIR ${DIR}

COPY *.py *.sh ${DIR}/

RUN \
    echo "---- install packages ----" && \
    apk add --no-cache --upgrade \
      bash \
      tzdata && \
    echo "---- setting timezone ----" && \
    ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
    echo "${TZ}" > /etc/timezone && \
    echo "---- install requirements ----" && \
    pip install requests && \
    echo "---- add crontabs ----" && \
    echo "*/5 * * * * python ${DIR}/checkStatus.py >> ${DIR}/logs/cron.log" >> /var/spool/cron/crontabs/root && \
    echo "---- rest work ----" && \
    chmod +x init.sh

USER $PUID:$PGID

ENTRYPOINT ["./init.sh"]
